/**
 * @class sf.b2c.mall.framework.adapter
 * @description adapter基类
 * @param  {Object} can
 * @param  {Object} _   underscore
 * @return {can.Map}
 */
define(['can', 'underscore'], function (can, _) {
  'use strict';

  return can.Map.extend({

    /**
     * @function sf.b2c.mall.framework.adapter.format
     * @description 对传输进来的数据进行格式化
     */
    format: function () {
      throw new Error('使用前必须被复写');
    },

    /**
     * @function sf.b2c.mall.framework.adapter.empty
     * @description 清空现在的attrs
     */
    empty: function () {
      var handler = _.bind(function (value, key) {
        this.removeAttr(key);
      }, this);
      this.each(handler);
    },

    /**
     * @function sf.b2c.mall.framework.adapter.replace
     * @description 清空现在的attrs之后设置
     * @param  {Map} attrs 需要设置的熟悉
     */
    replace: function (attrs) {
      this.empty();
      this.attr(attrs);
    }

  });

});